<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
    <script src="https://cdn.bootcss.com/vue-router/3.1.3/vue-router.min.js"></script>
</head>
<body>
    <div id="app">
        <router-link to="/user">用户管理</router-link>
        <router-link to="/car">汽车管理</router-link>
        <router-view></router-view>
    </div>

    <template id="t1">
        <div>
            用户管理界面 <br>
            <router-link to="/user/add">添加用户</router-link>
            <router-link to="/user/find">查看用户</router-link>
            <router-view></router-view>
        </div>
    </template>

    <template id="t1_1">
        <div>
            添加用户界面:
            name: <input type="text">
            <button>add user</button>
        </div>
    </template>

    <template id="t1_2">
        <div>
            查看用户界面：
            1 -- 张三 -- 22岁 <br>
            2 -- 李四 -- 23岁 <br>
            3 -- 王五 -- 24岁 <br>
        </div>
    </template>


    <template id="t2">
        <div>
            汽车管理界面
        </div>
    </template>

    <script>

        var userComponent = {
            template: "#t1"
        };
        var userAddComponent = {
            template: "#t1_1"
        };
        var userFindComponent = {
            template: "#t1_2"
        };


        var carComponent = {
            template: "#t2"
        }; 

        var router = new VueRouter({
            routes: [
                {
                    component: userComponent, path: "/user",     
                    children: [
                        {component: userAddComponent, path:"/user/add"},    
                        {component: userFindComponent, path:"/user/find"}   
                    ]
                },
                {component: carComponent, path:"/car"} 
            ]
        });

        var app = new Vue({
            el: "#app",
            router
        });
    </script>
</body>
</html>